using System;
using System.Collections.Generic;
using System.Text;

namespace MovieDB
{
    /// <summary>
    /// 艺人类
    /// 表示电影数据库中的艺人信息
    /// </summary>
    public class Artist
    {
        /// <summary>
        /// 艺人ID，主键
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 艺人姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 出生日期
        /// </summary>
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 性别（M/F）
        /// </summary>
        public char Sex { get; set; }

        /// <summary>
        /// IMDB编号
        /// </summary>
        public string ImdbNumber { get; set; }

        /// <summary>
        /// 艺人简介
        /// </summary>
        public string Introduction { get; set; }

        /// <summary>
        /// 导航属性：该艺人参与的电影
        /// </summary>
        public virtual ICollection<Movie> Movies { get; set; }

        /// <summary>
        /// 导航属性：该艺人的参与关系
        /// </summary>
        public virtual ICollection<Participation> Participations { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public Artist()
        {
            Movies = new HashSet<Movie>();
            Participations = new HashSet<Participation>();
        }

        /// <summary>
        /// 重写ToString方法，返回艺人的基本信息
        /// </summary>
        /// <returns>艺人信息字符串</returns>
        public override string ToString()
        {
            return $"Artist [ID={Id}, Name={Name}, Sex={Sex}, Birthday={(Birthday.HasValue ? Birthday.Value.ToShortDateString() : "未知")}]";
        }
    }

    /// <summary>
    /// 电影类
    /// 表示电影数据库中的电影信息
    /// </summary>
    public class Movie
    {
        /// <summary>
        /// 电影ID，主键
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 电影名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 上映日期
        /// </summary>
        public DateTime? ReleaseDate { get; set; }

        /// <summary>
        /// 电影时长（分钟）
        /// </summary>
        public int Duration { get; set; }

        /// <summary>
        /// 电影语言
        /// </summary>
        public string Language { get; set; }

        /// <summary>
        /// 电影简介
        /// </summary>
        public string Introduction { get; set; }

        /// <summary>
        /// 电影评级
        /// </summary>
        public float? Rating { get; set; }

        /// <summary>
        /// 导航属性：参与该电影的艺人
        /// </summary>
        public virtual ICollection<Artist> Artists { get; set; }

        /// <summary>
        /// 导航属性：该电影的参与关系
        /// </summary>
        public virtual ICollection<Participation> Participations { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public Movie()
        {
            Artists = new HashSet<Artist>();
            Participations = new HashSet<Participation>();
        }

        /// <summary>
        /// 重写ToString方法，返回电影的基本信息
        /// </summary>
        /// <returns>电影信息字符串</returns>
        public override string ToString()
        {
            return $"Movie [ID={Id}, Name={Name}, Duration={Duration}分钟, Rating={(Rating.HasValue ? Rating.Value.ToString("0.0") : "未评分")}, ReleaseDate={(ReleaseDate.HasValue ? ReleaseDate.Value.ToShortDateString() : "未知")}]";
        }
    }

    /// <summary>
    /// 参与关系类
    /// 表示艺人和电影之间的关联关系
    /// </summary>
    public class Participation
    {
        /// <summary>
        /// 参与关系ID，主键
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 艺人ID，外键
        /// </summary>
        public int ArtistId { get; set; }

        /// <summary>
        /// 电影ID，外键
        /// </summary>
        public int MovieId { get; set; }

        /// <summary>
        /// 角色名称
        /// </summary>
        public string RoleName { get; set; }

        /// <summary>
        /// 导航属性：关联的艺人
        /// </summary>
        public virtual Artist Artist { get; set; }

        /// <summary>
        /// 导航属性：关联的电影
        /// </summary>
        public virtual Movie Movie { get; set; }

        /// <summary>
        /// 重写ToString方法，返回参与关系的基本信息
        /// </summary>
        /// <returns>参与关系信息字符串</returns>
        public override string ToString()
        {
            return $"Participation [ArtistId={ArtistId}, MovieId={MovieId}, Role={RoleName ?? "未指定"}]";
        }
    }
}